package org.datascooter.impl;

import java.util.HashMap;
import java.util.Map;

import org.datascooter.inface.IDataSource;
import org.datascooter.inface.IDataSourceProvider;

/**
 * Simplest DataSourceProvider for zero config
 * 
 * @author nemo
 * 
 */
public class DummyDataSourceProvider implements IDataSourceProvider {

	private Map<String, IDataSource> dataSourceMap = new HashMap<String, IDataSource>();
	private IDataSource defaultSource;

	public DummyDataSourceProvider(IDataSource dataSource) {
		putSource(dataSource);
	}

	@Override
	public IDataSource getDefault() {
		return defaultSource;
	}

	@Override
	public void putSource(IDataSource dataSource) {
		dataSourceMap.put(dataSource.getName(), dataSource);
		if (dataSource.isCurrent()) {
			defaultSource = dataSource;
		}
	}

	@Override
	public void explore() throws Exception {
	}

	@Override
	public IDataSource getItem(String dname) {
		return dataSourceMap.get(dname);
	}

	@Override
	public void removeSource(String dname) {
		dataSourceMap.remove(dname);
	}
}
